import Taro from "@tarojs/taro"

export interface localStorageData {
	user: any
}
export default {
	/**
	 * 设置Storage
	 */
	setItem<T extends keyof localStorageData>(key: T, value: localStorageData[T]) {
		Taro.setStorageSync(key, value)
	},
	/**
	 * 读取Storage
	 * noConverted:不转换成对象
	 */
	getItem<T extends keyof localStorageData>(key: T): localStorageData[T] {
		let value = Taro.getStorageSync(key)
		if (!value) {
			return null
		}
		return value
	},
	/**
	 * 移除Storage
	 */
	removeItem(key: keyof localStorageData) {
		Taro.removeStorageSync(key)
	},
	/**
	 * 清空Storage
	 */
	clearItem() {
		Taro.clearStorageSync()
	}
}
